/**
 * Created by wangyin on 2017/11/16.
 */
define(["echarts"], function (require, exports) {

    //page加载完成后调用ready方法
    exports.ready = function (hashCode, data, cite) {
        yufp.lookup.reg('');/** EVENT_STATUS,BIZ_NODE_TYPE,PERSONAL_HANDLE_STATUS,FLOW_STATUS @qiuyf 2019/01/30 【一阶段无流程】*/
        var _self = yufp.custom.vue({
            el: cite.el,
            data: function () {
                var _self = this;
                return {
                    daiNum: 0,
                    asts: [],
                    dataUrl: backend.flowService + '/api/done/wait/dashboard',
                    tableColumns: [
                        {
                            label: '业务节点名称',
                            prop: 'bizNodeName'
                        },
                        {
                            label: '待办数量',
                            prop: 'bizNodeNum'
                        }
                    ],
                    selections: [],


                    dialogVisible:false,
                    formDisabled: true,
                    updateFields: [{
                        columnCount: 1,
                        fields: [
                            { field: 'mesId', label: '公告编号',disabled: true, placeholder: '系统自动生成' }
                        ]
                    },{
                        columnCount: 1,
                        fields: [
                            { field: 'title', label: '标题',type: 'textarea',rows:2}
                        ]
                    },{
                        columnCount: 1,
                        fields: [
                            { field: 'mess', label: '公告内容', type: 'textarea', rows:13}
                        ]
                    },{
                        columnCount: 2,
                        fields: [
                            { field: 'senderId', label: '发送人代码',disabled: true },
                            { field: 'mesType', label: '消息类型',type: 'select',width:'110px',dataCode: 'MES_TYPE'}
                        ]
                    },{
                        columnCount: 1,
                        fields: [
                            { field: 'userName', label: '发送人'}
                        ]
                    },{
                        columnCount: 2,
                        fields: [
                            { field: 'inputdate', label: '创建日期', disabled: true,type: 'date' },
                            { field: 'senddate', label: '发送日期', disabled: true,type: 'date' }
                        ]
                    }],
                    updateButtons: [
                        { label: '取消', type: 'primary', icon: 'yx-undo2', hidden: false, click: function (model) {
                                _self.dialogVisible = false;
                            } }
                    ]
                };
            },
            methods: {
                rowClickFn: function (row) {
                    this.selections = this.$refs.reftable.selections;
                    var temp = yufp.frame.tab('menu_lp-21000');
                    if (temp.index != -1) {
                        yufp.frame.removeTab('menu_lp-21000');
                    }
                    yufp.frame.addTab({
                        id: 'todoList',            //菜单功能ID（路由ID）
                        key: 'menu_lp-21000',  //'menu_'前缀加菜单ID
                        title: '待办事项',       //页签名称
                        data: {bizNodeName: row.bizNodeName}                //传递的业务数据，可选配置
                    });
                },
                astFn: function (value) {
                    _self.dialogVisible = true;
                    this.$nextTick(function () {
                        this.$refs.reform.rebuildFn();
                        yufp.extend(this.$refs.reform.formModel, value);
                    });
                },
                otherFn: function (value) {
                    var temp = yufp.frame.tab('menu_lp-24000');
                    if (temp.index != -1) {
                        yufp.frame.removeTab('menu_lp-24000');
                    }
                    yufp.frame.addTab({
                        id: 'AstSysMessagePageInfo',            //菜单功能ID（路由ID）
                        key: 'menu_lp-24000',  //'menu_'前缀加菜单ID
                        title: '公告发布',       //页签名称
                        data: {title: '', inputdate: '', userName: '', mesType: ''}                //传递的业务数据，可选配置
                    });
                },
                loadFn: function (data, total) {
                    var temp = 0;
                    for (var i = 0; i < data.length; i++) {
                        temp += parseInt(data[i].bizNodeNum);
                    }
                    _self.daiNum = temp;
                }
            },
            mounted: function () {
                yufp.service.request({
                    method: 'POST',
                    url: backend.consoleService + '/api/ast/sys/indexView',
                    data: {
                        orgIds: ''
                    },
                    callback: function (code, message, response) {
                        if (code == 0 && response.code == '0') {
                            // _self.$refs.reftable.remoteData();
                            _self.asts = response.rows;
                        } else {
                        }
                    }
                });
            }

        });
    };

    //消息处理
    exports.onmessage = function (type, message) {

    };

    //page销毁时触发destroy方法
    exports.destroy = function (id, cite) {

    };

});